package com.twu.biblioteca;

import com.twu.biblioteca.model.BookCollection;
import com.twu.biblioteca.model.MovieCollection;
import com.twu.biblioteca.util.MyScanner;

import java.io.PrintStream;
import java.util.Scanner;

/**
 * Created by mvargas on 5/2/14.
 */
public class Biblioteca {


    private final PrintStream printStream;
    private final MyScanner scanner;
    private boolean isRunnable;

    public Biblioteca(MyScanner scanner, PrintStream printStream) {
        this.scanner = scanner;
        this.printStream = printStream;
    }

    public void run(){
        printStream.println("Hello! This is a Library Management System of Bangalore Public Library.");
        BookCollection bookCollection = new BookCollection();
        MovieCollection movieCollection = new MovieCollection();
        Menu menu = new Menu(this, printStream, bookCollection, scanner, movieCollection);

        isRunnable = true;

        while(isRunnable){
            menu.showMenuOptions();

            printStream.println("\n\n");
            printStream.println("Please, select a option:");

            int selectedOption = scanner.nextInt();

            menu.getMenuOptionSelected(selectedOption);
        }
    }

    public void stopRun(){
        this.isRunnable = false;
    }

}
